package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @InterfaceName: DisheMapper
 * @Author: YuanDing
 * @Date: 2024/2/3 20:34
 * @Description: 菜品管理mapper层
 */

@Mapper
public interface DishesMapper {

    /**
     * 获取菜品分页数据
     * @return
     */
    Page<Dish> selectDishesByPageNumber(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 更新员工状态
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    /**
     * 根据id获取菜品
     * @param id
     * @return
     */
/*    @Select("select * from dish where id = #{id}")
    Dish selectDishById(Integer id);*/

    /**
     * 插入一条菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void insertDish(Dish dish);


    /**
     * 根据分类id获取菜品
     * @return
     */
    List<Dish> selectDisheByCategoryId(Integer categoryId);


    void deleteDishBatch(String[] idArr);

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @Select("select * from dish where category_id = #{categoryId} and status = #{status}")
    List<Dish> list(Dish dish);

    /**
     * 根据id查询菜品
     * @param dishId
     * @return
     */
    @Select("select * from dish where id = #{dishId}")
    Dish selectDishById(Long dishId);

    Integer countByMap(Map map);

    /**
     * 根据套餐id查询菜品
     * @param setmealId
     * @return
     */
    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long setmealId);
}
